//
//  SISSIntermediaryContractShowViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2019/7/5.
//  Copyright © 2019 优房网. All rights reserved.
//

#import "SISSIntermediaryContractShowViewController.h"
#import "SISSUploadIntermediaryContractViewController.h"
#import "SISSNetworkingManager+Progress.h"
#import "SISSHouseProgressModel.h"
#import "SISSHouseProgressRecordInfoModel.h"
#import "SISSPassengerProgressModel.h"
#import "SISSPassengerProgressRecordInfoModel.h"
#import "SISSIntermediaryContractModel.h"

@interface SISSIntermediaryContractShowViewController ()

///
@property (strong, nonatomic) SISSIntermediaryContractModel *intermediaryContractModel;

@end

@implementation SISSIntermediaryContractShowViewController

- (void)viewDidLoad {
    self.isHiddenDateChooseView = YES;
    [super viewDidLoad];
    
    self.title = @"居间服务合同详情";
    
    [self requestIntermediaryContractData];
}

- (void)requestIntermediaryContractData {
    NSString *ahbpId = self.houseProgressModel ? self.houseProgressModel.ahbpId : self.passengerProgressRecordInfoModel.ahbpId;
    NSString *adbpId = self.passengerProgressModel ? self.passengerProgressModel.adbpId : self.houseProgressRecordInfoModel.adbpId;
    NSInteger houseType = self.houseProgressModel ? 1 : self.passengerProgressRecordInfoModel.tradeBusinessType;
    NSInteger demandType = self.passengerProgressModel ? 1 : self.houseProgressRecordInfoModel.tradeBusinessType;
    if (houseType == 2) ahbpId = self.passengerProgressRecordInfoModel.ahrId;
    if (demandType == 2) adbpId = self.houseProgressRecordInfoModel.abdId;
    
    WeakSelf
    [kNetworkManager requestIntermediaryContractWithAhbpId:ahbpId adbpId:adbpId demandType:0 houseType:0 success:^(SISSIntermediaryContractModel *intermediaryContractModel) {
        
        weakSelf.intermediaryContractModel = intermediaryContractModel;
        weakSelf.contractNoView.rightStr = intermediaryContractModel.contractNum;
        weakSelf.remarkView.rightStr = intermediaryContractModel.otherdesc;
        weakSelf.createDateView.rightStr = intermediaryContractModel.insertTime;
        weakSelf.uploadImageShowView.imageUrlArr = intermediaryContractModel.image.mutableCopy;
        
    } failed:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

- (void)modifyButtonClickAction {
    SISSUploadIntermediaryContractViewController *vc = [[SISSUploadIntermediaryContractViewController alloc] init];
    vc.houseProgressModel = self.houseProgressModel;
    vc.houseProgressRecordInfoModel = self.houseProgressRecordInfoModel;
    vc.passengerProgressModel = self.passengerProgressModel;
    vc.passengerProgressRecordInfoModel = self.passengerProgressRecordInfoModel;
    vc.intermediaryContractModel = self.intermediaryContractModel;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
